package asia.kalin.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

/**
 * @Author: Kalin
 * @Name：DeekSeekJanusPro7BUtil
 * @Date: 2025/5/25
 * @description
 */
public class DeepSeekJanusPro7B1Util {

    public static String multimodalUnderstanding(String filename) {
        try {
            // 1. 定义命令及参数
            ProcessBuilder pb = new ProcessBuilder(
                    "python", // 或 "python3"，根据环境调整
                    "janus.py",
                    PromptUtil.prompt,
                    filename
            );

            // 可选：设置工作目录（如脚本不在当前目录）
            // pb.directory(new File("/path/to/script/directory"));
            pb.environment().put("PYTHONIOENCODING", "utf-8");

            // 2. 启动进程
            Process process = pb.start();

            // 3. 读取标准输出流
            InputStream inputStream = process.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
            String line;
            StringBuffer stringBuffer = new StringBuffer();
            while ((line = reader.readLine()) != null) {
                stringBuffer.append(line);
            }

            return String.valueOf(stringBuffer);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }

}
